package panda.client.listeners;

import panda.client.Cardpanda;
import panda.client.ui.widgets.Bin;
import panda.client.ui.widgets.NoteTip;

import com.google.gwt.user.client.ui.MouseListener;
import com.google.gwt.user.client.ui.Widget;

/**
 * Click on a bin to retrieve a card from it. This mouselistener is added by bins for testing.
 * 
 * @author zane.tian@gmail.com
 */
public class BinMouseListenerForBins implements MouseListener {
	private Bin bin;
	int xBound, yBound, xLeft, xRight, yTop, yBottom;

	public BinMouseListenerForBins(final Bin bin) {
		this.bin = bin;
	}

	public void onMouseDown(final Widget sender, int x, int y) {
		// System.out.println("clicked on " + bin.getName());
		if(!bin.isEmpty()) {
			// DraggableCard card = bin.removeTopCard();
			// Panda.canvas.add(card, 100, 100);
			// Panda.clientModel.addCardInPlay(card, 120, 120);
			
//			String logForMe = "You reveal " + card.getName() + " from your " + bin.getName();
//			String logForOthers = Panda.clientModel.getSessionID().getName() + " reveals " + card.getName() + " from " + Panda.clientModel.getSessionID().getName() + "'s " + bin.getName();
//			NoteTip.get().log(logForMe, logForOthers);
		}

		
		String name = Cardpanda.clientModel.getSessionID().getName();
		String logForMe = "You click on " + bin.getOwnerName() + "'s " + bin.getName();
		String logForOthers = name + " clicks on  " + bin.getOwnerName() + "'s " + bin.getName();
		NoteTip.get().log(logForMe, logForOthers);
		Cardpanda.sendModelUpdateToServer(Cardpanda.clientModel.getSessionID());
	}

	public void onMouseEnter(final Widget sender) {}

	public void onMouseLeave(final Widget sender) {}

	public void onMouseMove(final Widget sender, int x, int y) {}

	public void onMouseUp(final Widget sender, int x, int y) {}
}
